
import net.rim.device.api.system.EncodedImage;
import net.rim.device.api.ui.XYRect;


public class DiskManager {
	
	Disk[] disk;
	
	EncodedImage[] diskImg;
		
	public DiskManager (int numbDisk, int sectionWidth){
		disk = new Disk[numbDisk];
		diskImg = new EncodedImage[numbDisk];
		XYRect r;
		int diskWidth = sectionWidth - 5;
		int diskHeight = GameField.COLUMNHEIGHT/numbDisk;
		for (int i = 0; i < numbDisk; i++){
			r = new XYRect(GameField.COLUMNWIDTH + sectionWidth/2 - diskWidth/2
					, GameField.deviceHeight - (int) (diskHeight * (i+1)), diskWidth, diskHeight);
			disk[i] = new Disk(i+1, EncodedImage.getEncodedImageResource(
					"b" + (i+1) + ".png"), r);
			diskWidth = (int)(diskWidth * 0.8);
		}
	}
	
	public Disk[] getDisks(){
		return disk;
	}
	
	public int length(){
		return disk.length;
	}
}

class Disk {
	EncodedImage disk_img;
	public int position;
	public final int LEFT = 0;
	public final int MID = 1;
	public final int RIGHT = 2;
	boolean clicked = false;
	XYRect location;
	//1 is the smallest disk, 8 is the biggest.
	int sizeRank; //the bigger it is, smaller the disk is.
	
	public Disk (int sizeRank, EncodedImage img, XYRect loc) {
		position = LEFT;
		this.sizeRank = sizeRank;
		disk_img = img;
		location = loc;
	}
	
	public EncodedImage getImage(){
		return disk_img;
	}
	
	public XYRect getLocation(){
		return location;
	}
	
	public void setLocation(int x, int y){
		location.setLocation(x, y);
	}
	
	public boolean isClicked(){
		return clicked;
	}
	
	public void toggleClicked(){
		clicked = !clicked;
	}
	
}